from docx import Document

def docx_to_md(input_path, output_path):
    doc = Document(input_path)
    with open(output_path, 'w', encoding='utf-8') as f:
        for para in doc.paragraphs:
            # 简单处理标题
            if para.style.name.startswith('Heading'):
                level = para.style.name.split(' ')[-1]
                f.write('#' * int(level) + ' ' + para.text + '\n')
            else:
                f.write(para.text + '\n\n')

input_file = '文档.docx'
output_file = '文章.md'
docx_to_md(input_file, output_file)